<!DOCTYPE html>
<html lang="zh">
<head>
  <th:block th:include="include :: header('基本表单')"/>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <form class="form-horizontal" id="grid-project-form" th:object="${data}">
        <input type="hidden" th:field="*{id}" placeholder="id"/>
        <div class="form-group">
          <label class="col-sm-3 control-label">项目名称: </label>
          <div class="col-sm-8">
            <input type="text" th:field="*{name}" placeholder="项目名称" class="form-control"/>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">作者: </label>
          <div class="col-sm-8">
            <input th:field="*{author}" placeholder="email" class="form-control"></input>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">email: </label>
          <div class="col-sm-8">
            <input th:field="*{email}" placeholder="email" class="form-control"></input>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">项目包名: </label>
          <div class="col-sm-8">
            <input th:field="*{pkgName}" placeholder="项目包名" class="form-control"></input>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">模块名称: </label>
          <div class="col-sm-8">
            <input th:field="*{modelName}" placeholder="模块名称" class="form-control"></input>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">模板路径: </label>
          <div class="col-sm-8">
            <input th:field="*{templatePath}" placeholder="模板路径" class="form-control"></input>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">版本: </label>
          <div class="col-sm-8">
            <input th:field="*{version}" placeholder="版本" class="form-control"></input>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">生成方式: </label>
          <div class="col-sm-8">
            <div class="radio">
              <label class="radio-box"> <input type="radio" th:field="*{genType}" value="0"/> zip压缩包 </label>
              <label class="radio-box"> <input type="radio" th:field="*{genType}" value="1"/> 自定义路径</label>
            </div>
          </div>
        </div>
        <div class="form-group hidden" id="pathinfo">
          <label class="col-sm-3 control-label">输出路径: </label>
          <div class="col-sm-8">
            <input th:field="*{codePath}" placeholder="输出路径" class="form-control"></input>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "gen/project";

    function submitHandler() {
        var data = $("#grid-project-form").serialize();
        $.ajax({
            cache : true,
            type : "put",
            url : prefix + "/update",
            data : data,
            async : false,
            error : function(req) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function pathInfoVisible(genType) {
        if("0" == genType){
            $("#pathinfo").addClass("hidden");
        } else if("1" == genType){
            $("#pathinfo").removeClass("hidden");
        }
    }

    $(function() {
        var genType = $('input[name="genType"]:checked').val();
        pathInfoVisible(genType);
    });

    $('input[name="genType"]').on('ifChecked', function(event){
        var genType = $(event.target).val();
        pathInfoVisible(genType);
    });

</script>
</body>
</html>
